module.exports = async function (taskNoteId) {
  const taskNote = await api.getNote(taskNoteId);
  
  if (!taskNote) {
    return;
  }
    
  if (taskNote.getParentNotes().some((m) => m.hasLabel("todoArchive"))) {
    return;
  } 
    
  const todoInProgress = (
    await taskNote.getParentNotes()[0].getParentNotes()[0].getChildNotes()
  ).find((m) => m.hasLabel("todoInProgress"))?.noteId;
  
  if (!todoInProgress) {
    return;
  }
    
  const oldParentNoteId = taskNote.getParentNotes()[0].noteId;
  
  await taskStartTracking(taskNoteId);
    
  await api.toggleNoteInParent(true, taskNote.noteId, todoInProgress);

  await api.toggleNoteInParent(false, taskNote.noteId, oldParentNoteId);
  //await taskNote.removeRelation("location",oldParentNoteId);
  taskNote.removeRelation("location");
  taskNote.setRelation("location", todoInProgress);  
};
 
